package helpers.other
{
	import define.Text;
	
	import flash.utils.setTimeout;
	
	import mx.containers.VBox;
	
	public class VShowBox extends VBox
	{
		private var _rowCount:int = 4;
		
		public function VShowBox()
		{
			super();
			addLabel("");
			addLabel("");
			addLabel("");
		}
		
		public function get rowCount():int
		{
			return _rowCount;
		}

		public function set rowCount(value:int):void
		{
			_rowCount = value;
		}
		
		public function addLabel(label:String):void
		{
			while(this.numChildren >= _rowCount){// >= 的作用是 当rowCount被修改后，避免溢出
				removeHead();
			}
			this.push(label);
		}
		
		private function removeHead():void
		{
			this.removeChildAt(0);
		}
		
		private function push(label:String):void
		{
			var line:Text = new Text();
			line.htmlText = label;
			line.width = this.width;
			this.addChild(line);
			setTimeout(startDisplay,2000,line);
		}
		
		private function startDisplay(line:Text):void
		{
			if(line.alpha>0.2){
				line.alpha -= 0.05;
				setTimeout(startDisplay,100,line);
			}
			else
			{
				line.alpha = 0;
			}
		}

	}
}